home *** CD-ROM | disk | FTP | other *** search
- Path: news.mira.net.au!news
- From: davidw@werple.net.au (David White)
- Newsgroups: comp.lang.c++,gnu.g++.help
- Subject: Re: Forward declarations of typedefs
- Date: 29 Feb 1996 20:07:47 +1100
- Organization: Werple Internet, Melbourne
- Message-ID: <4h3qd3$esa@werple.net.au>
- References: <4h2fhp$si8@elaine22.Stanford.EDU>
- NNTP-Posting-Host: werple.mira.net.au
-
- iburrell@leland.Stanford.EDU (Ian Burrell) writes:
-
- >I am trying to do a forward declaration of a type defined in another
- >header so that I can make a class member that is a pointer. However,
- >if the forward declaration type is later defined as a typedef, I get
- >lots of errors.
-
- >Is there a way to consistently make forward declarations that works
- >with later typedefs? Does the method work if the type representation
- >later changes? How about anonymous structs defined in a typedef?
-
- >Here is a snippet of example code and the errors it gives:
-
- >struct test;
-
- >test* t;
-
- >struct _test
- >{
- > int a;
- >};
-
- >typedef _test test;
-
- 'test' cannot be declared as both a struct in its own right and an alias
- for 'struct _test'. The only struct here is '_test', not 'test'.
- It is not necessary to have '_test', e.g.,
-
- //In one header
- struct test
- {
- int a;
- };
-
- //In the other
- struct test;
-
- test *t;
-
- David White
- davidw@werple.mira.net.au
-